package com.lu.service;

import com.lu.bean.AppException;
import com.lu.constant.ErrorEnum;
import com.lu.dao.mapper.WgRiddleMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * @author luke
 * @className RiddleService
 * @description
 * @date 2021/07/13 10:24
 */
@Slf4j
@Service
public class RiddleService {
    @Resource
    private WgRiddleMapper wgRiddleMapper;

    public String[] queryRiddle() throws AppException {
        //TODO 做出随机，且不重复的数据效果
        System.out.println("------------开始查询谜底数据库------------");
        String[] riddles = wgRiddleMapper.queryRiddle();
        if(riddles == null || riddles.length == 0) {
            throw new AppException(ErrorEnum.PARAM_EMPTY.code,"数据为空");
        }
        return riddles;
    }

    public String[] queryRiddle2(){
        //TODO 做出随机，且不重复的数据效果
        String[] riddles = wgRiddleMapper.queryRiddle();
        if(riddles != null || riddles.length > 0) {
            return null;
        }
        return riddles;
    }


}
